package com.fortune.rainshinecommon.util;

import org.springframework.web.multipart.MultipartFile;

/**
 * @program: rainShine
 * @description:
 * @author: tangyn
 * @create: 2019-06-04
 **/
public class OssFileNameUtils {
    public static String getNewName(MultipartFile file, String floder, String rannum){
        String newName = floder + "_" + rannum;
        String fileName = file.getOriginalFilename();
        String suffix = fileName.substring(fileName.lastIndexOf("."));
        return newName+suffix;
    }

    public static String getNewNameWithIndex(MultipartFile file, String floder, Integer id, Short sort) {
        String newName = floder + "_" + id + "_" + sort;
        String fileName = file.getOriginalFilename();
        String suffix = fileName.substring(fileName.lastIndexOf("."));
        return newName+suffix;
    }

    public static String getFilePath(String part,String fileName){
        return "shengxian/"+part+"/"+fileName;
    }

    public static String getNewNameForIdCard(MultipartFile file,String floder,Integer id,String type){
        String newName = floder + "_" +type + "_"+id;
        String fileName = file.getOriginalFilename();
        String suffix = fileName.substring(fileName.lastIndexOf("."));
        return newName+suffix;
    }

}
